#include<iostream>
using namespace std;
int n, x, y;
int a[10100], b[10100], g[10100], k[10100];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d%d%d%d", &a[i], &b[i], &g[i], &k[i]);
    }
    scanf("%d%d", &x, &y);
    int clo = -1;
    for (int i = n; i >= 1; i--)
    {
        if (a[i] <= x && a[i] + g[i] >= x && b[i] <= y && b[i] + k[i] >= y)
        {
            clo = i;
            break;
        }
    }
    cout << clo << endl;
    return 0;
}